﻿@{
    Layout = "_LayoutBody";
}
<div class="pagebox" id="pageContentId">
    <div class="home-desktop">
        <div class="title">
            <div class="name left">供应商列表</div>
            <div class="function left">[&nbsp;<a href="javascript:;" onclick="definedLayer('@Url.Action("AddView")',{},'html');">添加</a>&nbsp;]</div>
            <div class="clear"></div>
        </div>
        <div class="condition-box">
            <div class="condition-items">
                <span class="condition-title">名称：</span><input type="text" id="txt_suplierName" class="condition-txt">
                <span class="condition-title">短名：</span><input type="text" id="txt_shortName" class="condition-txt">
                <span class="condition-title">纳税人识别号：</span><input type="text" id="txt_identityNumber" class="condition-txt">
            </div>
            <div class="condition-items">
                <button type="button" class="cotrlBtn btnBlue" id="btn_search"><i class="icon-search"></i>&nbsp;查询</button>
            </div>
            <div class="clear"></div>
        </div>
        <div class="area">
            <!--内容列表开始-->
            <table class="data" cellpadding="0" cellspacing="0" id="basicSupplier_table" style="table-layout: fixed">
                <thead>
                    <tr>
                        <th class="text-left" style="width: 60px;">
                            <label for="checkall">
                                <input id="checkall" type="checkbox" class="group-checkable check-item" data-set="#basicSupplier_table .check-item" />全选
                            </label>
                        </th>
                        <th>类别</th>
                        <th>名称</th>
                        <th>短名</th>
                        <th>纳税人识别号</th>
                        <th>认证状态</th>
                        <th>使用状态</th>
                        <th>创建时间</th>
                        <th class="text-right">操作</th>
                    </tr>
                </thead>
                <tbody></tbody>
            </table>
            <!--内容列表结束-->
            <!--分页-->
            <div class="pages">
                <div class="left">
                    <button type="button" class="cotrlBtn btnDefault" id="btn_delete"><i class="icon-del"></i>批量删除</button>
                </div>
                <div id="primarykeypage" class="right pageDiv text-right">
                </div>
                <div class="clear"></div>
            </div>
            <!--分页结束-->
        </div>
    </div>
    <!--列表双击效果-->
</div>

<script id="temp_basicSupplier" type="text/html">
    <!--总行数-->
    <input type="hidden" id="page_total" value="{{data.totalCount}}" />
    {{if  data.items!=null && data.items!="" && data.items!=undefined && data.items.length>0 }}
    {{each data.items as item i}}
<tr id="{{item.id}}">
    <td class="text-left">
        <label>
            <span>
                <input type="checkbox" class="check-item" value="{{item.id}}">
            </span>
        </label>
    </td>
    <td>{{item.supplierTypeStr}}</td>
    <td>{{item.supplierName}}</td>
    <td>{{item.shortName}}</td>
    <td>{{item.identityNumber}}</td>
    <td>{{item.greenAVLStatusStr}}</td>
    <td>{{item.useStatusStr}}</td>
    <td>{{dateFormat(item.createTime,'yyyy-MM-dd')}}</td>
    <td class="text-right">
        <div class="dataTabs-ctrol-down">
            <span class="dataTabs-ctrol-btn">选项操作<i class="icon-down"></i></span>
            <div class="dataTabs-ctrol-info">
                <a href="javascript:" onclick="definedLayer('@Url.Action("EditView")', { id: {{ "'" + item.id + "'"}}}, 'html', {});">编辑</a>
                <a href="javascript:" onclick="del('{{item.id}}','确定删除吗？');" class="">删除</a>
            </div>
        </div>
    </td>
</tr>
    {{/each}}
    {{else}}
    <tr class="lastrow">
        <td colspan="9">
            <label>暂无数据</label>
        </td>
    </tr>
    {{/if}}
</script>
<script type="text/javascript">
    var pageObj = new Pager({ params: { "suplierName": "txt_suplierName", "shortName": "txt_shortName", "identityNumber": "txt_identityNumber"} }, {
        url: "@Url.Action("Search")",
        obj: $('#primarykeypage'),
        autoLoad: true
    }, function (json) {
            var html = template('temp_basicSupplier', JSON.parse(json));
            $('#basicSupplier_table').find("tbody").html(html);
            GroupCheckable_Change("basicSupplier_table");
        $(".dataTabs-ctrol-down").on("click", ".dataTabs-ctrol-btn", function () {
            var _this = $(this);
            if ($(this).hasClass("curr")) {
                $(this).removeClass("curr");
                $(this).closest('.dataTabs-ctrol-down').find('.dataTabs-ctrol-info').slideUp(100);
                $(this).find('i').rotate(0);
            } else {
                $(this).addClass("curr");
                $(this).closest('.dataTabs-ctrol-down').find('.dataTabs-ctrol-info').slideDown(100);
                $(this).find('i').rotate(180);
                $(this).closest('tr').siblings("tr").find('.dataTabs-ctrol-info').slideUp(100);
                $(this).closest('tr').siblings("tr").find('.dataTabs-ctrol-btn').removeClass("curr");
                $(this).closest('tr').siblings("tr").find('.dataTabs-ctrol-btn').find('i').rotate(0);
            }
            $("body").unbind("click").one("click", function () {
                _this.removeClass("curr");
                _this.closest('.dataTabs-ctrol-down').find('.dataTabs-ctrol-info').slideUp(100);
                _this.find('i').rotate(0);
            });
            return false;
        });
        $(".dataTabs-ctrol-down").on("click", ".dataTabs-ctrol-info", function (e) {
            e.stopPropagation();
        });
    });
    // 查询按钮单击事件
    function btn_search_click() {
        pageObj.moveFirst();
    }
    // 查询按钮单击事件
    $("#btn_search").click(function () {
        btn_search_click();
    });

    //批量删除
    $("#btn_delete").click(function () {
        //获取选中的值
        var rows = GetSelectRowOfCheckbox('basicSupplier_table', 0, true);
        if (rows == "") {
            dcTips("请至少选择一条数据", 3000, 2);
            return false;
        }
        del(rows.join(","), "确定批量删除选择的数据吗？");
    });
    //删除
    function del(id, msg) {
        dcConfirm(msg, function () {
            $.post("@Url.Action("Delete")", { ids: id }, function (result) {
                if (result.code == 0) {
                    dcAlert(result.message, 0, 1, function () {
                        //刷新显示数据
                        btn_search_click();
                    });
                }
                else {
                    dcAlert(result.message, 0, 2);
                }
            });
        });
    }
</script>
